package com.micro.common.service.web.service.open;

import cn.hutool.core.bean.BeanUtil;
import com.micro.common.service.orm.entity.DictDataPo;
import com.micro.common.service.orm.param.DictQueryParam;
import com.micro.common.service.orm.service.DictDataServiceImpl;
import com.micro.common.service.web.client.api.DictOpenApi;
import com.micro.common.service.web.client.domain.req.DictQueryReq;
import com.micro.common.service.web.client.domain.resp.DictListResp;
import com.micro.framework.starter.common.data.result.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.List;

@Service
public class DictOpenApiService implements DictOpenApi {
    @Resource
    private DictDataServiceImpl dictDataService;

    @Override
    public Result<List<DictListResp>> dictList(DictQueryReq req) {
        List<DictDataPo> poList =  dictDataService.getBaseMapper().dicPageList(null, DictQueryParam.builder().groupCode(req.getGroupCode()).build());
        return Result.success(BeanUtil.copyToList(poList,DictListResp.class));
    }

}
